#include <glib.h>

void _file_utils_dir_func(const gchar *path)
{
    const gchar *name = NULL;
    GDir *dir = NULL;
    gchar *fullname = NULL;
    GError *error;

    if(NULL == path) {
        g_print("param is NULL \n");
        return;
    }

    dir = g_dir_open(path, 0, &error);

    while(NULL != (name = g_dir_read_name(dir))){
        fullname = g_strconcat(path, "/", name, NULL);
        if(g_file_test(fullname, G_FILE_TEST_IS_DIR)) {
            g_print("D:%s \n", fullname);
            _file_utils_dir_func(fullname);
        } else {
            g_print("F:%s \n", fullname);
        }
        g_free(fullname);
    }

    g_dir_close(dir);
}

void test_file_utils_dir_func(void)
{
    g_print("\n");
    _file_utils_dir_func(".");
}

gint main(gint argc, gchar **argv)
{
    g_test_init(&argc, &argv, NULL);

    g_test_add_func("/file_utils/dir", test_file_utils_dir_func);

    return g_test_run();
}
